package greedyAlgorithm;

import java.util.Arrays;

//https://leetcode.cn/problems/assign-cookies/
public class FindContentChildren {
    public int findContentChildren(int[] g, int[] s) {
        // g 胃口值
        Arrays.sort(g);
        // s 饼干尺寸
        Arrays.sort(s);

        // 定义返回值
        int count = 0;

        // 定义开始时间
        int start = 0;

        for (int i = 0; i < s.length && start < g.length; i++) {
            if (s[i] >= g[start]) {
                start++;
                count++;
            }
        }
        return count;
    }
}
